home *** CD-ROM | disk | FTP | other *** search
- #include "xdefs.h"
- #include "xbmtools.h"
-
- /*
- ;-----------------------------------------------------------------------
- ; x_pbm_to_bm
- ;
- ; This function converts a bitmap in the planar format to the linear format
- ; as used by x_compile_bitmap.
- ;
- ; WARNING: the source and destination bitmaps must be pre - allocated
- ;
- ; NOTE: This function can only convert planar bitmaps that are suitable.
- ; If the source planar bitmap's width (per plane) is >= 256/4
- ; it cannot be converted. In this situation an error code
- ; BM_WIDTH_ERROR. On successful conversion 0 is returned.
- ;
- ; C callable as:
- ; int x_pbm_to_bm(char far * source_pbm, char far * dest_bm);
- ;
- ; Written By Themie Gouthas
-
- // converted to C++ by Maciej Kalisiak
-
- */
-
- int x_pbm_to_bm( char * pbm, char * lbm)
- {
- WORD width=pbm[0]<<2;
- WORD height=pbm[1];
-
- if( width>255 )
- return 1;
-
- lbm[0]=width;
- lbm[1]=pbm[1];
-
- WORD size=width*height;
- for( WORD offs=0;offs<size;offs++ )
- *(lbm+ 2+ (offs*4)%size+ (offs*4)/size)=pbm[offs+2];
-
- return 0;
- }
-
- int x_bm_to_pbm( char * lbm, char * pbm )
- {
- WORD width=lbm[0];
- WORD height=lbm[1];
-
- pbm[0]=width>>2;
- pbm[1]=lbm[1];
-
- // WORD offs=0;
- // for( WORD y=0;y<height;y++ )
- // for( WORD x=0;x<width;x+=4 )
- // {
- // lbm[offs+2]=*(pbm+ 2+ y*width+ x);
- // offs++;
- // }
-
- WORD size=width*height;
- for( WORD offs=0;offs<size;offs++ )
- pbm[offs+2]=*(lbm+ 2+ (offs*4)%size+ (offs*4)/size);
-
- return 0;
- }
-
-
-
-